package cpm.cloud.feign.fallback;

import com.test.entities.HandDepartments;
import cpm.cloud.feign.FeignClientService;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author dell
 */
@Component
public class FeignClientServiceFallBack implements FallbackFactory<FeignClientService>{


    @Override
    public FeignClientService create(Throwable throwable) {
        return new FeignClientService(){

            @Override
            public HandDepartments findById(Long id) {
                HandDepartments departments = new HandDepartments();
                departments.setDepartmentId(id);
                departments.setDepartmentCode("该ID没有对应的部门编号信息");
                departments.setDepartmentName("该ID没有对应的部门名称信息");
                return departments;
            }

            @Override
            public List<HandDepartments> findAll() {
                return null;
            }

            @Override
            public HandDepartments add(HandDepartments departments) {
                HandDepartments departments1 = new HandDepartments();
                departments.setDepartmentCode("客户端超时，添加失败");
                departments.setDepartmentName("客户端超时，添加失败");
                return departments1;
            }

            @Override
            public void delete(Long id) {

            }
        };
    }
}
